<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:attribute-set name="textblock">
		<xsl:attribute name="font-family">Helvetica, Arial</xsl:attribute>
		<xsl:attribute name="font-size">7pt</xsl:attribute>
		<xsl:attribute name="space-before">1pt</xsl:attribute>		
		<xsl:attribute name="space-after">1pt</xsl:attribute>		
	</xsl:attribute-set>
	<xsl:attribute-set name="textblock1">
		<xsl:attribute name="font-family">Helvetica, Arial</xsl:attribute>
		<xsl:attribute name="font-size">7pt</xsl:attribute>
		<xsl:attribute name="space-before">0pt</xsl:attribute>		
		<xsl:attribute name="space-after">0pt</xsl:attribute>		
	</xsl:attribute-set>
	<xsl:attribute-set name="textblockimportant">		
		<xsl:attribute name="font-size">8pt</xsl:attribute>
		<xsl:attribute name="font-weight">bold</xsl:attribute>
	</xsl:attribute-set>
	<xsl:attribute-set name="pageNumber">
		<xsl:attribute name="font-family">Arial</xsl:attribute>
		<xsl:attribute name="font-size">9pt</xsl:attribute>		
	</xsl:attribute-set>	
	<xsl:attribute-set name="headerText">
		<xsl:attribute name="font-family">Arial</xsl:attribute>
		<xsl:attribute name="font-size">8pt</xsl:attribute>
		<xsl:attribute name="font-style">italic</xsl:attribute>					
	</xsl:attribute-set>
	<xsl:attribute-set name="title">
		<xsl:attribute name="font-family">Arial</xsl:attribute>
		<xsl:attribute name="font-size">15pt</xsl:attribute>
		<xsl:attribute name="font-weight">bold</xsl:attribute>
		<xsl:attribute name="text-align">center</xsl:attribute>	
		<xsl:attribute name="margin-bottom">7mm</xsl:attribute>	
	</xsl:attribute-set>
	<xsl:attribute-set name="specialOffer">
		<xsl:attribute name="color">red</xsl:attribute>		
		<xsl:attribute name="font-weight">bold</xsl:attribute>		
	</xsl:attribute-set>
	<xsl:attribute-set name="clearanceStock">
		<xsl:attribute name="color">red</xsl:attribute>				
	</xsl:attribute-set>
	<xsl:param name="showFOB"><xsl:value-of select="//bulkorders/showfob" /></xsl:param>
	
	<xsl:template match="/">
		<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
			<!-- defines the layout master -->
			<fo:layout-master-set>
				<fo:simple-page-master master-name="first" page-height="297mm" page-width="210mm" margin-top="5mm" margin-bottom="5mm"
					margin-left="5mm" margin-right="5mm">
					<fo:region-body margin-top="15mm" margin-bottom="5mm" />
					<fo:region-before extent="15mm" />
					<fo:region-after extent="5mm" />
				</fo:simple-page-master>
			</fo:layout-master-set>
			<!-- starts actual layout -->
			<fo:page-sequence master-reference="first">
				<fo:static-content flow-name="xsl-region-after">
					<fo:block xsl:use-attribute-sets="pageNumber">Page <fo:page-number/></fo:block>
				</fo:static-content>
				<fo:static-content flow-name="xsl-region-before">
					<fo:table table-layout="fixed" width="100%" border-bottom-style="solid" border-bottom-width="1pt">
						<fo:table-column column-width="150mm" />
						<fo:table-column column-width="50mm" />
						<fo:table-body>
							<fo:table-row>
								<fo:table-cell number-columns-spanned="2" text-align="center">
									<fo:block xsl:use-attribute-sets="title">Immediate Delivery Stock Report</fo:block>
								</fo:table-cell>
							</fo:table-row>
							<fo:table-row>
								<fo:table-cell text-align="left" >
									<fo:block xsl:use-attribute-sets="headerText">"<xsl:value-of select="//bulkorders/conpoint" />" - Port: "<xsl:value-of select="//bulkorders/loadingport" />" container loading: <xsl:value-of select="//bulkorders/containerloading" /></fo:block>
								</fo:table-cell>
								<fo:table-cell text-align="right" >
									<fo:block xsl:use-attribute-sets="headerText">(to convert cm to inches divide by 2.54)</fo:block>
								</fo:table-cell>
							</fo:table-row>
						</fo:table-body>
					</fo:table>					
				</fo:static-content>
				<fo:flow flow-name="xsl-region-body">					
					<!-- table start -->
					<fo:table table-layout="fixed">
						<fo:table-column column-width="50%" />
						<fo:table-column column-width="50%" />
						<fo:table-body>
							<xsl:for-each select="bulkorders/bulkorder">
								<xsl:if test="position() mod 2 != 0">
									<fo:table-row height="54mm">
										<fo:table-cell>
											<fo:table table-layout="fixed">
												<fo:table-column column-width="50mm" />
												<fo:table-column />
												<fo:table-body>
													<fo:table-row height="52mm">
														<fo:table-cell>
															<xsl:element name="fo:external-graphic">
																<xsl:attribute name="src">url('<xsl:value-of select="./productimagepath" />')</xsl:attribute>
																<xsl:attribute name="height">100%</xsl:attribute>
																<xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
																<xsl:attribute name="scaling">uniform</xsl:attribute>
																<xsl:attribute name="content-width">100%</xsl:attribute>
															</xsl:element>
														</fo:table-cell>
														<fo:table-cell padding-left="1mm" padding-right="1mm" xsl:use-attribute-sets="textblock">
															<fo:block xsl:use-attribute-sets="textblockimportant textblock">Code: <xsl:value-of select="./productcode" /></fo:block>															
															<xsl:if test="starts-with(./catalogname,'LGD')">
																<fo:block xsl:use-attribute-sets="textblock">Catalogue Page: <xsl:value-of select="./page" /></fo:block>
															</xsl:if>
															<fo:block xsl:use-attribute-sets="textblock">Color:<xsl:value-of select="./color" /></fo:block>
															<fo:block xsl:use-attribute-sets="textblock">Desc: <xsl:value-of select="./salesdescription1" /></fo:block>
															<fo:block xsl:use-attribute-sets="textblock" text-indent="5mm">
																<xsl:value-of select="./salesdescription2" />
															</fo:block>
															<xsl:if test="./isProductRound = 'false'">
																<fo:block xsl:use-attribute-sets="textblock" text-indent="12mm"><![CDATA[ ]]><![CDATA[ ]]><![CDATA[ ]]><xsl:value-of select="./TextForTitleRow" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="./TextForDiaOrLengthRow" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="./TextForWidthRow" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="./TextForHeightRow" /></fo:block>
															</xsl:if>
															<xsl:if test="./isProductRound = 'true'">
																<fo:block xsl:use-attribute-sets="textblock" text-indent="12mm"><![CDATA[ ]]><![CDATA[ ]]><![CDATA[ ]]><xsl:value-of select="./TextForTitleRow" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="./TextForDiaOrLengthRow" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="./TextForHeightRow" /></fo:block>
															</xsl:if>
												<fo:table table-layout="fixed">
												<fo:table-column column-width="45%" /><fo:table-column column-width="5%"/><fo:table-column column-width="15%" /><fo:table-column column-width="15%"/><fo:table-column column-width="15%"/><fo:table-column column-width="15%"/>
												<fo:table-body>
													<fo:table-row height="3mm">
														<fo:table-cell>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">S1</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">S2</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">S3</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">S4</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">S5</fo:block>
														</fo:table-cell>
													</fo:table-row>
														<fo:table-row height="3mm">
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">Dia   (cm)</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>

														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
													</fo:table-row>
														<fo:table-row height="3mm">
														<fo:table-cell ><fo:block xsl:use-attribute-sets="textblock1">Height (cm)</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5</fo:block>
														</fo:table-cell>
														<fo:table-cell><fo:block xsl:use-attribute-sets="textblock1">30.5 30.5 30.5</fo:block>
														</fo:table-cell>
													</fo:table-row>

												</fo:table-body>
											</fo:table>
															<fo:block xsl:use-attribute-sets="textblock">Qty avail: <xsl:value-of select="./idsqtyavail" /><![CDATA[ ]]><xsl:value-of select="./idsqtyavaildesc" /></fo:block>
															<xsl:if test="$showFOB = 1">
																<xsl:if test="isspecialoffer = 1">
																	<fo:block xsl:use-attribute-sets="specialOffer textblock">FOB: <xsl:value-of select="./fob" /></fo:block>																	
																</xsl:if>
																<xsl:if test="isspecialoffer = 0">
																	<fo:block xsl:use-attribute-sets="textblock">FOB: <xsl:value-of select="./fob" /></fo:block>
																</xsl:if>															
															</xsl:if>
															<fo:block xsl:use-attribute-sets="textblock">Minimum order: <xsl:value-of select="./minorderqty" /></fo:block>
															<fo:block xsl:use-attribute-sets="textblock">Tall pallet qty(for info): <xsl:value-of select="./tallpalletqty" /></fo:block>
															<fo:block xsl:use-attribute-sets="textblock">Supplier No: <xsl:value-of select="./suppliercode" /><![CDATA[ ]]><xsl:value-of select="./typecode" /><![CDATA[ ]]><xsl:value-of select="./ownercode" /><![CDATA[ ]]><xsl:value-of select="./stocklocation" /></fo:block>
															<xsl:if test="./idssort = 'CLEARANCE STOCK'">
																<fo:block xsl:use-attribute-sets="clearanceStock">Clearance Stock - Priced to Clear !</fo:block>
															</xsl:if>
														</fo:table-cell>
													</fo:table-row>
												</fo:table-body>
											</fo:table>
										</fo:table-cell>
										<fo:table-cell>
											<xsl:if test="position() &lt; last()">
												<fo:table table-layout="fixed">
													<fo:table-column column-width="50mm" />
													<fo:table-column />
													<fo:table-body>
														<fo:table-row height="52mm">
															<fo:table-cell>
																<xsl:element name="fo:external-graphic">
																	<xsl:attribute name="src">url('<xsl:value-of select="following-sibling::bulkorder[1]/productimagepath" />')</xsl:attribute>
																	<xsl:attribute name="height">100%</xsl:attribute>
																	<xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
																	<xsl:attribute name="scaling">uniform</xsl:attribute>
																	<xsl:attribute name="content-width">100%</xsl:attribute>
																</xsl:element>
															</fo:table-cell>
															<fo:table-cell padding-left="1mm" padding-right="1mm" xsl:use-attribute-sets="textblock">
																<fo:block xsl:use-attribute-sets="textblockimportant textblock">Code: <xsl:value-of select="following-sibling::bulkorder[1]/productcode" /></fo:block>
																<xsl:if test="starts-with(following-sibling::bulkorder[1]/catalogname,'LGD')">
																	<fo:block xsl:use-attribute-sets="textblock">Catalogue Page: <xsl:value-of select="following-sibling::bulkorder[1]/page" /></fo:block>
																</xsl:if>
																<fo:block xsl:use-attribute-sets="textblock">Color: <xsl:value-of select="following-sibling::bulkorder[1]/color" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock">Desc: <xsl:value-of select="following-sibling::bulkorder[1]/salesdescription1" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock" text-indent="5mm">
																	<xsl:value-of select="following-sibling::bulkorder[1]/salesdescription2" />
																</fo:block>
																<xsl:if test="./isProductRound = 'false'">
																	<fo:block xsl:use-attribute-sets="textblock" text-indent="12mm"><![CDATA[ ]]><![CDATA[ ]]><![CDATA[ ]]><xsl:value-of select="following-sibling::bulkorder[1]/TextForTitleRow" /></fo:block>
																	<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="following-sibling::bulkorder[1]/TextForDiaOrLengthRow" /></fo:block>
																	<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="following-sibling::bulkorder[1]/TextForWidthRow" /></fo:block>
																	<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="following-sibling::bulkorder[1]/TextForHeightRow" /></fo:block>
																</xsl:if>
																<xsl:if test="./isProductRound = 'true'">
																	<fo:block xsl:use-attribute-sets="textblock" text-indent="12mm"><![CDATA[ ]]><![CDATA[ ]]><![CDATA[ ]]><xsl:value-of select="following-sibling::bulkorder[1]/TextForTitleRow" /></fo:block>
																	<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="following-sibling::bulkorder[1]/TextForDiaOrLengthRow" /></fo:block>
																	<fo:block xsl:use-attribute-sets="textblock"><xsl:value-of select="following-sibling::bulkorder[1]/TextForHeightRow" /></fo:block>
																</xsl:if>
																<fo:block xsl:use-attribute-sets="textblock">Qty avail: <xsl:value-of select="following-sibling::bulkorder[1]/idsqtyavail" /><![CDATA[ ]]><xsl:value-of select="following-sibling::bulkorder[1]/idsqtyavaildesc" /></fo:block>
																<xsl:if test="$showFOB = 1">
																	<xsl:if test="following-sibling::bulkorder[1]/isspecialoffer = 1">
																		<fo:block xsl:use-attribute-sets="specialOffer textblock">FOB: <xsl:value-of select="following-sibling::bulkorder[1]/fob" /></fo:block>																	
																	</xsl:if>
																	<xsl:if test="following-sibling::bulkorder[1]/isspecialoffer = 0">
																		<fo:block xsl:use-attribute-sets="textblock">FOB: <xsl:value-of select="following-sibling::bulkorder[1]/fob" /></fo:block>
																	</xsl:if>																	
																</xsl:if>
																<fo:block xsl:use-attribute-sets="textblock">Minimum order: <xsl:value-of select="following-sibling::bulkorder[1]/minorderqty" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock">Tall pallet (for info): <xsl:value-of select="following-sibling::bulkorder[1]/tallpalletqty" /></fo:block>
																<fo:block xsl:use-attribute-sets="textblock">Supplier No: <xsl:value-of select="following-sibling::bulkorder[1]/suppliercode" /><![CDATA[ ]]><xsl:value-of select="following-sibling::bulkorder[1]/typecode" /><![CDATA[ ]]><xsl:value-of select="following-sibling::bulkorder[1]/ownercode" /><![CDATA[ ]]><xsl:value-of select="./stocklocation" /></fo:block>
																<xsl:if test="following-sibling::bulkorder[1]/idssort = 'CLEARANCE STOCK'">
																	<fo:block xsl:use-attribute-sets="clearanceStock">Clearance Stock - Priced to Clear !</fo:block>
																</xsl:if>
															</fo:table-cell>
														</fo:table-row>
													</fo:table-body>
												</fo:table>
											</xsl:if>
										</fo:table-cell>
									</fo:table-row>
								</xsl:if>
							</xsl:for-each>
						</fo:table-body>
					</fo:table>
					<!-- table end -->
				</fo:flow>
			
			</fo:page-sequence>
		</fo:root>
	</xsl:template>
</xsl:stylesheet>
